# -*- coding：utf-8 -*-
"""
@Time:2024-10-0615:53
@Auth:泛彼泊舟
@File:yaml_Util.py
@IDE:PyCharm
@模块功能：读写yaml文件
"""

# 读取
import yaml


from common.file_path import EXTRACT_PATH

# 读取
def read_yaml(key):
    with open(EXTRACT_PATH, encoding="utf-8") as f:
        value = yaml.safe_load(f)
        return value[key]

# 读取extract.yaml里面的所有值
def read_all():
    with open(EXTRACT_PATH, encoding="utf-8") as f:
        value = yaml.safe_load(f)
        return value

# 写入
def write_yaml(data):
    with open(EXTRACT_PATH, encoding="utf-8", mode="a") as f:
        yaml.safe_dump(data,f,allow_unicode=True)

# 情况
def clear_yaml():
    with open(EXTRACT_PATH, encoding="utf-8", mode="w") as f:
        pass

# 读取用例
def read_testcase(yaml_path):
    with open(yaml_path, encoding="utf-8") as f:
        value = yaml.safe_load(f)
        return value

